<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>


    <script>

        // 
        // Object.prototype.toString.call()   判断所有的数据类型


        // console.log(Object.prototype.toString.call(1));

        // console.log(Object.prototype.toString.call('hi'));

        // console.log(Object.prototype.toString.call(true));

        // console.log(Object.prototype.toString.call(null));

        // console.log(Object.prototype.toString.call(undefined));

        // console.log(Object.prototype.toString.call([]));

        // console.log(Object.prototype.toString.call({ a: 1 }));




        function type(data) {
            const res = Object.prototype.toString.call(data);
            if (res === '[object Number]') {
                return 'number'
            }
            if (res === '[object String]') {
                return 'string'
            }
            if (res === '[object Boolean]') {
                return 'boolean'
            }
            if (res === '[object Array]') {
                return 'array'
            }

            if (res === '[object Object]') {
                return 'object'
            }
            if (res === '[object Null]') {
                return 'null'
            }
            if (res === '[object Undefined]') {
                return 'undefined'
            }
            if (res === '[object Function]') {
                return 'function'
            }
        }


        // console.log(type(null));


        // function Person() {

        // }

        // Person.prototype.say = function () {
        //     console.log(1);
        // }

        // Person.prototype.say();

    </script>

</body>

</html>